rm(list=setdiff(ls(),c("wkdir")))
#################################################
# Parties paper
# Replication File: Oligarchy or Class War?
#  
# Author(s):  Matt Grossmann, William Isaac, Zuhaib Mahmood
# Created:    3.28.18
# Updated:	  11.12.18
#
# This replication file is self-contained. It should run without any changes by the user.
################################################

suppressMessages(library(ggplot2))
suppressMessages(library(magrittr))
suppressMessages(library(plyr))
suppressMessages(library(dplyr))
suppressMessages(library(stargazer))
suppressMessages(library(texreg))
suppressMessages(library(grid))
suppressMessages(library(gridExtra))
suppressMessages(library(xtable))
suppressMessages(library(weights))
suppressMessages(library(ggplot2))
suppressMessages(library(margins))
suppressMessages(library(reshape2))

if(!("wkdir" %in% ls())){
	wkdir<-getwd()
}
in_path<-wkdir
script_path_sections<-wkdir

stopifnot(dir.exists(in_path))
stopifnot(dir.exists(script_path_sections))

##########
#Load files
##########
setwd(in_path) 
aic_df <- read.csv("./full_gsd_with_latent_weights_4317_revised.csv" , sep ="," ,  header = TRUE,	stringsAsFactors=F)
options("scipen" = 10)

############
#Prep dataset
############
setwd(script_path_sections)
source("0_dataprep.R")

############
#Run scripts
############

#Estimate the main models
setwd(script_path_sections)
source("1_main_models.R")

#Descriptive statistics
setwd(script_path_sections)
source("2_descriptives.R")